function setValue(key, value) {
  wx.setStorageSync(key, value)
}

function getValue(key) {
  return wx.getStorageSync(key)
}

function delKey(key) {
  wx.removeStorage({
    key: key
  })
}

function currentPatient() {
  let cachePtList = getValue("patient");
  let currentPatient = null
  if (cachePtList != undefined && cachePtList != null && cachePtList.length > 0) {
    cachePtList.forEach(m => {
      if (m.crtFlag == "Y") {
        currentPatient = m;
        return currentPatient;
      }
    })
  }
  return currentPatient
}

function delAll() {
  wx.clearStorage()
}
module.exports = {
  setValue,
  getValue,
  delKey,
  delAll,
  currentPatient
}